<?php
declare (strict_types = 1);

namespace app\middleware;

use app\constant\App;

class Auth
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        if (empty($request->header("App-Id") || !in_array($request->header("App-Id"), array_keys(App::APP_LIST)))) {
            return json(['code' => 500, 'msg'  => '非法请求'], 500);
        }
        if (empty($request->header("App-Student-No"))) {
            return json(['code' => 500, 'msg'  => '非法请求'], 500);
        }

        return $next($request);
    }
}
